import Foundation

public struct TraceConfig {
    /// 是否开启埋点功能
    public var isEnabled: Bool = true
    
    /// 服务器URL
    public var serverURL: String = "https://api.example.com/vichat_api/api/v1/trace/record/add"
    
    /// 上报策略
    public var uploadStrategy: UploadStrategy = .default
    
    /// 缓存策略
    public var cacheStrategy: CacheStrategy = .default
    
    /// 应用渠道
    public var channel: String = "App Store"
    
    /// 是否自动采集应用生命周期事件
    public var autoTrackAppLifecycle: Bool = true
    
    /// 是否自动采集页面浏览事件
    public var autoTrackPageView: Bool = true
    
    /// 是否自动采集点击事件
    public var autoTrackClick: Bool = true
    
    /// 是否自动采集崩溃事件
    public var autoTrackCrash: Bool = true
    
    public init() {}
}

/// 上报策略
public struct UploadStrategy {
    /// 定时上报间隔（秒）
    public var interval: TimeInterval = 60
    
    /// 定量上报阈值
    public var threshold: Int = 10
    
    /// 是否在应用进入后台时上报
    public var uploadWhenAppEnterBackground: Bool = true
    
    /// 默认策略
    public static var `default`: UploadStrategy {
        return UploadStrategy()
    }
}

/// 缓存策略
public struct CacheStrategy {
    /// 最大缓存事件数
    public var maxEvents: Int = 1000
    
    /// 最大缓存天数
    public var maxDays: Int = 7
    
    /// 默认策略
    public static var `default`: CacheStrategy {
        return CacheStrategy()
    }
}